package com.zijin;

import com.zijin.Dao.DeptMapper;
import com.zijin.Dao.EmpMapper;
import com.zijin.entity.Dept;
import com.zijin.entity.Emp;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.util.List;


public class App5 {
    public static void main(String[] args) {
        SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(
                App.class.getClassLoader().getResourceAsStream("mybatisConf.xml"));
//打开一个会话 ，会话会占用资源，不需要时要关闭
        SqlSession ss = ssf.openSession();
        //获得EmpMapper接口实现类
        EmpMapper empMapper = ss.getMapper(EmpMapper.class);//获得动态代理

        //查询empid为5
        //Emp emp=empMapper.selectEmpByEmpid(5);

        //查询deptid为2
        //List<Emp> list=empMapper.selectAllEmp(2);

        //增加一条数据
        int result=empMapper.insertEmp(new Emp(7,"sey","yuangong"));
        System.out.println(result);
        ss.close();
    }
}